﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AppPort;
using TI;
using TiEntityObject.Notification;

namespace Controllers.AdministrationControllerCommands
{
    /// <summary>
    /// Вернуть список документов за день
    /// </summary>
    public class GetDayDocuments
    {
        private class inGetDayDocuments { 
            public long Day { get; set; }
            public string DragName {get;set;}
            public bool OnlyStage1 {get;set;}
        }
       
        private class outGetDayDocuments : DocumentMetaItem
        {
            public Notification Notification { get; set; }           
        }

        public static string Run(ServiceCmd cmd) {
            inGetDayDocuments ip = Helper.Json<inGetDayDocuments>.NewtonDeserializeObject(cmd.args.ToString());
            var script = "getDayDocuments(" +cmd.Limit.ToString() +","+cmd.Start.ToString() + ","  + ip.Day.ToString() + ",'" + ip.DragName+".*" + "'," + ip.OnlyStage1.ToString().ToLower() +  ")";
            List<outGetDayDocuments> lst = Helper.MongoTools.Instance.GetCollection<outGetDayDocuments>(script);
            string s = Helper.Json<outGetDayDocuments>.ListToJson(lst);
            return "{success:true, total:1000, d:"+s+"}";
        }
    }
}
